home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / DrawPixel.s < prev    next >
Encoding:
Text File  |  1998-09-05  |  3.2 KB  |  141 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This demo draws a pixel on a screen without destroying the background.
  3.  
  4.     INCDIR    "GMSDev:Includes/"
  5.     INCLUDE    "dpkernel/dpkernel.i"
  6.  
  7.     SECTION    "DrawPixel",CODE
  8.  
  9. ;===========================================================================;
  10. ;                             INITIALISE DEMO
  11. ;===========================================================================;
  12.  
  13.     STARTDPK
  14.  
  15. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  16.     move.l    DPKBase(pc),a6
  17.     lea    FILE_Background(pc),a0    ;Load the picture.
  18.     moveq    #ID_PICTURE,d0
  19.     CALL    Load
  20.     move.l    d0,PIC_Background
  21.     beq.s    .Exit
  22.  
  23.     moveq    #ID_SCREEN,d0
  24.     CALL    Get
  25.     move.l    d0,Screen
  26.     beq.s    .Exit
  27.  
  28.     move.l    PIC_Background(pc),a0
  29.     move.l    Screen(pc),a1
  30.     CALL    CopyStructure
  31.  
  32.     move.l    Screen(pc),a0
  33.     sub.l    a1,a1
  34.     CALL    Init
  35.     tst.l    d0
  36.     beq.s    .Exit
  37.  
  38.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  39.     CALL    Get
  40.     move.l    d0,JoyData
  41.     beq.s    .Exit
  42.     move.l    d0,a0    ;Initialise the joydata structure.
  43.     sub.l    a1,a1
  44.     CALL    Init
  45.     tst.l    d0
  46.     beq.s    .Exit
  47.  
  48.     move.l    PIC_Background(pc),a0
  49.     move.l    PIC_Bitmap(a0),a0
  50.     move.l    Screen(pc),a1
  51.     move.l    GS_Bitmap(a1),a1
  52.     CALL    Copy
  53.  
  54.     move.l    Screen(pc),a0
  55.     CALL    Show
  56.  
  57.     bsr.s    Main
  58.  
  59. .Exit    move.l    DPKBase(pc),a6
  60.     move.l    JoyData(pc),a0
  61.     CALL    Free
  62.     move.l    Screen(pc),a0
  63.     CALL    Free
  64.     move.l    PIC_Background(pc),a0
  65.     CALL    Free
  66.     MOVEM.L    (SP)+,A0-A6/D1-D7
  67.     moveq    #ERR_OK,d0
  68.     rts
  69.  
  70. ;===========================================================================;
  71. ;                                MAIN LOOP
  72. ;===========================================================================;
  73.  
  74. Main:    moveq    #100,d6
  75.     moveq    #100,d7
  76. .loop    move.l    BLTBase(pc),a6
  77.  
  78.     ;Replace the background pixel.
  79.  
  80.     move.l    Screen(pc),a0
  81.     move.l    GS_Bitmap(a0),a0
  82.     movem.w    OldPixel(pc),d1/d2/d3
  83.     tst.w    d3
  84.     blt.s    .read
  85.     CALL    bltDrawPixel    ;>> = Draw the old background pixel.
  86.  
  87.     ;Read the new background pixel.
  88.  
  89. .read    move.l    Screen(pc),a0
  90.     move.l    GS_Bitmap(a0),a0
  91.     move.w    d6,d1    ;d1 = X Coordinate.
  92.     move.w    d7,d2    ;d2 = Y Coordinate.
  93.     CALL    bltReadPixel    ;>> = Read the pixel.
  94.     movem.w    d6/d7,OldPixel    ;MA = Save coords of next pixel.
  95.     move.w    d0,OldPixel+4    ;MA = Save colour of next pixel.
  96.  
  97.     ;Draw the pixel.
  98.  
  99.     move.l    Screen(pc),a0
  100.     move.l    GS_Bitmap(a0),a0
  101.     move.w    d6,d1    ;d1 = X Coordinate.
  102.     move.w    d7,d2    ;d2 = Y Coordinate.
  103.     move.w    #3,d3    ;d3 = Colour.
  104.     CALL    bltDrawPixel    ;>> = Draw our pixel.
  105.  
  106.     move.l    SCRBase(pc),a6
  107.     CALL    scrWaitAVBL    ;>> = Wait for VBL.
  108.  
  109.     move.l    DPKBase(pc),a6
  110.     move.l    JoyData(pc),a0
  111.     CALL    Query
  112.     move.l    JoyData(pc),a0
  113.     add.w    JD_YChange(a0),d7
  114.     add.w    JD_XChange(a0),d6
  115.     move.l    JD_Buttons(a0),d0
  116.     btst    #JB_LMB,d0
  117.     beq.s    .loop
  118.     rts
  119.  
  120. OldPixel:
  121.     dc.w    0,0,-1
  122.  
  123. ;===========================================================================;
  124. ;                                  DATA
  125. ;===========================================================================;
  126.  
  127. JoyData:     dc.l  0
  128. Screen:         dc.l  0
  129. PIC_Background:     dc.l  0
  130. FILE_Background: FILENAME "GMS:demos/data/PIC.Green"
  131.  
  132. ;===========================================================================;
  133.  
  134. ProgName:    dc.b  "Draw Pixel",0
  135. ProgAuthor:    dc.b  "Paul Manias",0
  136. ProgDate:    dc.b  "January 1998",0
  137. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  138. ProgShort:    dc.b  "Pixel demonstration.",0
  139.         even
  140.  
  141.